package Work.ArrayLIst;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

public class arrayLIst {
    public static void main(String[] args) {

        ArrayList<Student> list = new ArrayList<>();

        Student a = new Student();
        a.setId(1);
        a.setName("张三");
        Student b = new Student();
        b.setId(2);
        b.setName("李四");
        Student c = new Student();
        c.setId(3);
        c.setName("王五");

        list.add(a);
        list.add(b);
        list.add(c);

        for (int i = 0; i < list.size(); i++) {

            System.out.println(list.get(i));

        }

        System.out.println("-------------------------------------");

        for (int i = 0; i < list.size(); i++) {

            if (list.get(i).getName().equals("张三")) {

                list.get(i).setName("张三丰");

            }

        }

        for (int i = 0; i < list.size(); i++) {

            System.out.println(list.get(i));

        }

        System.out.println("-------------------------------------");

        for (int i = 0; i < list.size(); i++) {

            if (list.get(i).getName().equals("王五")) {

                list.remove(i);

            }

        }

        for (int i = 0; i < list.size(); i++) {

            System.out.println(list.get(i));

        }

    }
}